package logic

import (
	"context"
	"shop/shop"

	"houseapi/internal/svc"
	"houseapi/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CommentAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCommentAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommentAddLogic {
	return &CommentAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CommentAddLogic) CommentAdd(req *types.CommentAddRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	comment, err := l.svcCtx.ShopSrv.CommentAdd(l.ctx, &shop.CommentAddRequest{
		UserId:  req.UserId,
		HouseId: req.HouseId,
		Comment: req.Comment,
	})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: err.Error(),
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "评论成功",
		Data:    comment,
	}, nil
}
